package de.fhaugsburg.games.boardgames.tests;

import static org.junit.Assert.*;

import java.util.Set;
import java.util.TreeSet;

import org.junit.Before;
import org.junit.Test;

import de.fhaugsburg.games.boardgames.GridPoint;

public class GridPointTest {
	private GridPoint point1;
	private GridPoint point2;
	private GridPoint point3;
	private Set<GridPoint> points;

	@Before
	public void setUp() throws Exception {
		point1 = new GridPoint(1,1);
		point2 = new GridPoint(2,2);
		point3 = new GridPoint(1,1);
		points = new TreeSet<GridPoint>();
		points.add(new GridPoint(4,1));
		points.add(new GridPoint(8,1));
		points.add(new GridPoint(3,1));
		points.add(new GridPoint(9,1));
		points.add(new GridPoint(5,1));
	}

	@Test
	public void testClone() {
		assertEquals(point1, point1.clone());
	}

	@Test
	public void testNeg() {
		assertEquals(new GridPoint(-2,-2),point2.neg() );
	}

	@Test
	public void testPlus() {
		assertEquals(point1.plus(point1), point2);
	}

	@Test
	public void testMinus() {
		assertEquals(point2.minus(point1), point1);
	}

	@Test
	public void testIsManhattanColinearWith() {
		assertTrue(point1.isManhattanColinearWith(points));
	}

	@Test
	public void testEqualsObject() {
		assertTrue(point1.row == point3.row && point1.col == point3.col );
	}

	@Test
	public void testCompareTo() {
		assertEquals(1, point2.compareTo(new GridPoint(2,0)));
	}
	

}
